package com.gopay.scheduler.shedulerx.remote;
import com.gopay.common.constants.scheduler.SchedulerConstants;
import com.gopay.scheduler.GopaySchedulerFactory;

import org.springframework.beans.factory.BeanNameAware;
import org.springframework.remoting.caucho.HessianServiceExporter;


/**
 * @author 19371
 */
public class SchedulerHessianServiceExporter extends HessianServiceExporter implements BeanNameAware {

    private String exportName;

    @Override
    public void setService(Object service) {
        super.setService(service);
    }

    @Override
    public void setServiceInterface(Class serviceInterface) {
        super.setServiceInterface(serviceInterface);
    }


    @Override
    public void setBeanName(String name) {
        if(!SchedulerConstants.PROJECT_NAME_CRON_RPC_PATH.equals(name)){
            try {
                throw new IllegalAccessException("the rpc path is wrong");
            } catch (IllegalAccessException e) {
                logger.error(String.format("the rpc path is wrong ; the realPath is %s , the error path is %s",SchedulerConstants.PROJECT_NAME_CRON_RPC_PATH,name),e);
            }
        }else {
            this.exportName = name;
        }
    }

    public String getName(){
        return this.exportName;
    }
}
